<?php
namespace App\Http\Controllers\ApiQd;

use App\Service\ApiQd\IndexService;
use Illuminate\Http\Request;

class IndexController extends BaseController
{
    //首页

    public function __construct()
    {
        $this->db = new IndexService();
    }

    //品牌列表
    public function getBrandIndex(Request $request)
    {
        $token = $request->post('token', '');
        $this->db->addApiCount($token);
        $res = $this->db->getBrandIndex();
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }

    //品牌详情
    public function getBrandOne(Request $request)
    {
        $token = $request->post('token', '');
        $this->db->addApiCount($token);
        $id = $request->post('id', 0);
        $res = $this->db->getBrandOne($id);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }

    //轮播图
    public function bannerList()
    {
        $res = $this->db->bannerIndex();
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }
}